﻿<html>
    <head>
        <title>Блог</title>
        <link rel='stylesheet' type='text/css' href='main.css'> 
    </head>
    
    <body>
        <div class='hat'><a href='index.php'>Блог</a>
        </div>
        
        <div class='auth'>
        Здравствуй, <?=$this->user->fName.' '.$this->user->lName?>!<br><br>
        
        <? if ( $this->user->id == false ) {?>
            <form action='index.php?controller=auth' method='post'>
                <input type='text' size='10' name='userName'>
                <input type='password' size='10' name='password'>
                <input type='submit' value='login'>
                &nbsp <a href='index.php?controller=reg'>[Регистрация]</a>
            </form>
        <? } else {?>
        <a href='index.php?controller=write'>Новая статья</a>
        &nbsp | &nbsp
        <a href='index.php?controller=index&logout=1'>Выйти</a>
        <? if ( $this->user->userName == 'admin' ) {?>
        &nbsp | &nbsp
        <a href='index.php?controller=admin'>Авторы</a>
        <?}?>
        <br><br>
        <? } ?>
        </div>
        <? if ( $this->user->userName == 'admin' ) { ?>
        
            <div class='users'>
                <?foreach($this->users as $user) {?>
                <div class='user'>
                    <div class='user_id'>id: <b><?=$user->id?></b> - <a href='index.php?controller=admin&delUser=<?=$user->id?>'>Удалить</a></div>
                    <div class='user_login'>login: <?=$user->userName?></div>
                    <div class='user_name'>Имя: <?=$user->fName?> <?=$user->lName?></div>
                </div>
                <?}?>
            </div>
        <? } else { ?>
            <div class='no_access'>
            У тебя нет доступа к этому разделу
            </div>
        <? } ?>
    </body>
</html>